package com.common.bean;


import org.json.JSONException;
import org.json.JSONObject;

import com.common.allCommon.JSONObjecthelper;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;



/**
 * 抱团审核通知消息结构体
 * <br>Created 2014-5-7 下午8:31:25
 * @version  
 * @author   linsj		
 *
 * @see 	 
 */
public class FansGroupAuditData extends AppMsgData implements Parcelable {
	/**抱团审核通知消息推送原因码　KEY名*/
	public static String KEY_AUDIT_TYPE = "type";	
	/**推送消息 key名*/
	public static String KEY_AUDIT_MSG = "msg";
	
	/**您的XX团入团申请已被拒绝 */
	public static final int CHNG_TYPE_REFUSE = 1;
	/**您的XX团入团申请已失效,请重新申请 */
	public static final int CHNG_TYPE_REAPPLY = 2;
	/**您的XX团入团申请已通过*/
	public static final int CHNG_TYPE_THROUGH = 9;
	
	/**推送原因代码*/
	public int iType = 0;
	/**推送消息*/
	public String strMsg = "";	
	
	
	/**
	 * Creates a new instance of NourishData.
	 *
	 */
	public FansGroupAuditData(){
		
	}
	
	public static final Parcelable.Creator<FansGroupAuditData> CREATOR = new Parcelable.Creator<FansGroupAuditData>() {
		public FansGroupAuditData createFromParcel(Parcel in) {
			return new FansGroupAuditData(in);
		}

		public FansGroupAuditData[] newArray(int size) {
			return new FansGroupAuditData[size];
		}
	};

	@Override
	public int describeContents() {
		return 0;
	}
	
	
	/**
	 * 序列化入
	 * <br>Created 2014-5-7 下午8:33:06
	 * @param in 序列化入
	 */
	private FansGroupAuditData(Parcel in) {
		super.parcelInData(in);
		iType = in.readInt();
		strMsg = in.readString();
	}
	
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		super.writeToParcel(dest, flags);
		dest.writeInt(iType);
		dest.writeString(strMsg);
	}

	@Override
	public void parseJson(String strJson) {
		if(TextUtils.isEmpty(strJson)){
			return;
		}	
		
		JSONObject jsonData = null;
		try {
			jsonData = new JSONObject(strJson);
		} catch (JSONException e) {
			return;
		}
		
		iType = JSONObjecthelper.getInt(jsonData, KEY_AUDIT_TYPE);
		strMsg = JSONObjecthelper.getString(jsonData, KEY_AUDIT_MSG);
	}
}
